<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org" >

<head>
    <meta charset="UTF-8">
    <title>欢迎页面</title>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="/css/font.css">
    <link rel="stylesheet" href="/css/xadmin.css">
    <script type="text/javascript" src="/js/jquery-3.2.1.min.js"></script>
    <script src="/lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="/js/xadmin.js"></script>
</head>

<body>
<div class="x-nav">
      <span class="layui-breadcrumb">
        <a href="">首页</a>
        <a href="">人事调配管理</a>
        <a>
          <cite>人事调配</cite></a>
      </span>
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <div class="layui-row">
        <form class="layui-form layui-col-md12 x-so">
            <input type="text" name="username" placeholder="请输入员工编号"  autocomplete="off" class="layui-input">
            <input type="text" name="username" placeholder="请输入员工姓名" autocomplete="off" class="layui-input">
            <button class="layui-btn" lay-submit="" lay-filter="sreach"><i class="layui-icon">&#xe615;</i></button>
        </form>
    </div>
    <form action="/deploy/excelWrite" >
        <button class="layui-btn layui-btn-danger" type="button" onclick="delAll()"><i class="layui-icon"></i>批量删除</button>
        <button class="layui-btn" type="button" onclick="x_admin_show('添加用户','/deploy/add',600,400)"><i class="layui-icon"></i>添加</button>
        <button class="layui-btn" type="submit"><i class="layui-icon">&#xe67d;</i>excel导出</button>
        <span class="x-right" style="line-height:40px">共有数据：11 条</span>
    </form>
    <table class="layui-table">
        <thead>
        <tr>
            <th>
                <div class="layui-unselect header layui-form-checkbox" lay-skin="primary"><i
                        class="layui-icon">&#xe605;</i></div>
            </th>
            <th>ID</th>
            <th>员工编号</th>
            <th>姓名</th>
            <th>原职务</th>
            <th>新职务</th>
            <th>调动时间</th>
            <th>调用原因</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody>
        <tr th:each="deploy : ${list}">
            <td>
                <input type="checkbox" th:value="${deploy.deployId}">
            </td>
            <td th:text="${deploy.deployId}"></td>
            <td th:text="${deploy.employId}"></td>
            <td th:text="${deploy.e_name}" style="font-weight: bold" onclick="show(this)">
            </td>
            <td th:text="${deploy.beforePost}"></td>
            <td th:text="${deploy.newPost}"></td>
            <td th:text="${#dates.format(deploy.time,'yyyy-MM-dd')}"></td>
            <td th:text="${deploy.remarks}"></td>
            <td class="td-manage">
                <a title="编辑" onclick="update(this)" href="javascript:;">
                    <i class="layui-icon">&#xe642;</i>
                </a>
                <a title="删除" onclick="member_del(this)" href="javascript:;" >
                    <i class="layui-icon">&#xe640;</i>
                </a>
                <a title="删除" onclick="sendEmail(this)" href="javascript:;">
                    <i class="layui-icon">&#xe609;</i>
                </a>
                <a onclick="x_admin_show('上传文件','member-password.html',600,400)" title="上传文件" href="javascript:;">
                    <i class="layui-icon">&#xe681;</i>
                </a>
            </td>
        </tr>
        </tbody>
    </table>
    <div class="page">
        <div>
            <a class="prev" href="">&lt;&lt;</a>
            <a class="num" href="">1</a>
            <span class="current">2</span>
            <a class="num" href="">3</a>
            <a class="num" href="">489</a>
            <a class="next" href="">&gt;&gt;</a>
        </div>
    </div>

</div>
<script>
    layui.use('laydate', function () {
        var laydate = layui.laydate;

        //执行一个laydate实例
        laydate.render({
            elem: '#start' //指定元素
        });

        //执行一个laydate实例
        laydate.render({
            elem: '#end' //指定元素
        });
    });

    //显示所有信息
    function show(obj) {
        //获取用户当前行的uId
        var employeeId=$(obj).parents("tr").find("td").eq(2).text();

        console.log("employeeId==>"+employeeId);
        //打开弹窗
        x_admin_show("查看用户","/deploy/show?employeeId="+employeeId);
    }

    //编辑方法
    function update(obj) {
        //获取用户当前行的uId
        var deployId=$(obj).parents("tr").find("td").eq(1).text();

        console.log("deployId==>"+deployId);
        //打开弹窗
        x_admin_show("修改用户","/deploy/update?deployId="+deployId);
    }

    /*用户-删除*/
    function member_del(obj) {
        var deployId = $(obj).parents("tr").find("td").eq(1).text();
        console.log(deployId);
        layer.confirm('确认要删除吗？',function(index) {
            $.ajax({
                url: "/deploy/send",
                async: false,
                type: "post",
                dataType: "json",
                data: {deployId: deployId},
                success: function (data) {
                    if (data == true) {
                        $(obj).parents("tr").remove();
                        layer.msg('fa', {icon: 1,time:1000});
                    }else{
                        layer.msg('删除失败', {icon: 1,time:1000});
                    }
                },
            })
        });
    }


    //批量删除
    function delAll () {
        //获取复选框选中的用户的uId
        var deployIds="";
        $('input[type=checkbox]:checked').each(function() {
            deployIds+=$(this).val()+",";
            //给选中的复选框 加样式
            $(this).parents("tr").addClass("dddd");
        });
        console.log(deployIds+"<====deployIds");
        layer.confirm('确认要删除吗？'+deployIds,function(index){
            $.ajax({
                url:"/deploy/delAll",
                async: false,
                type:"POST",
                dataType: "json",
                data:{deployIds:deployIds},
                success: function(data){
                    if(data==true){
                        layer.msg('删除成功', {icon: 1});
                        //删除选中的tr
                        $(".dddd").remove();
                    }else{
                        layer.msg('删除失败!',{icon: 1,time:1000});
                    }

                }
            })
        });
    }

    /*用户-发送邮件*/
    function sendEmail(obj, id) {
        layer.confirm('确认要发送吗？', function (index) {
            $.ajax({
                url:'/deploy/send',
                type:'post',
                dataType:'json',
                success:function (data) {
                    if (data.code == 0){
                        layer.msg('发送成功!', {icon: 1, time: 1000});
                    }else {
                        layer.msg('发送失败1!', {icon: 6, time: 1000});
                    }
                },
                error:function () {
                    layer.msg('发送失败!', {icon: 6, time: 1000});
                }
            });
        });
    }
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>

</html>